package top.wuliaodebaozi2.yunpan;

import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.appcompat.app.AppCompatActivity;

public class PrivacyPolicyAndUserAgreementActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_privacy_policy_and_user_agreement);

//        pdfView = findViewById(R.id.pdfView);

        Intent intent = getIntent();
        int privacyPolicyType = intent.getIntExtra("PrivacyPolicyType", 0);
        //获得控件
        WebView webView = (WebView) findViewById(R.id.wv_webview);
        if (privacyPolicyType == 0) {
            //访问网页
            webView.loadUrl("http://47.92.208.158/%E6%97%A0%E8%81%8A%E7%9A%84%E5%8C%85%E5%AD%90%E4%BA%91%E7%9B%98%E5%BA%94%E7%94%A8%E9%9A%90%E7%A7%81%E6%94%BF%E7%AD%96_%E4%B8%8A%E7%BA%BF.htm");
//            pdfView.fromAsset("隐私政策_上线.pdf").load();
        }else if (privacyPolicyType == 1) {
            //访问网页
            webView.loadUrl("http://wuliaodebaozi2.top/%E7%94%A8%E6%88%B7%E5%8D%8F%E8%AE%AE.htm");
//            pdfView.fromAsset("用户协议.pdf").load();
        } else if (privacyPolicyType == 2) {
            //访问网页
            webView.loadUrl("http://wuliaodebaozi2.top/%E5%84%BF%E7%AB%A5%E9%9A%90%E7%A7%81%E4%BF%9D%E6%8A%A4%E5%A3%B0%E6%98%8E.htm");
//            pdfView.fromAsset("用户协议.pdf").load();
        }

        //系统默认会通过手机浏览器打开网页，为了能够直接通过WebView显示网页，则必须设置
        webView.setWebViewClient(new WebViewClient(){
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                //使用WebView加载显示url
                view.loadUrl(url);
                //返回true
                return true;
            }
        });
    }


    @Override
    public void onBackPressed() {
        super.onBackPressed();
        finish();
    }
}